#:kivy 2.0.0

<NMTesterGame>:
    padding: 30
    spacing: 20

    canvas:
        Color:
            rgba: 0.95, 0.95, 0.98, 1
        Rectangle:
            pos: self.pos
            size: self.size

    Label:
        text: 'NMtester - 软件测试模拟游戏'
        font_size: '28sp'
        bold: True
        color: 0.2, 0.4, 0.8, 1
        size_hint_y: None
        height: 60

    # 统计信息区域
    BoxLayout:
        orientation: 'horizontal'
        size_hint_y: None
        height: 120
        spacing: 10

        BoxLayout:
            orientation: 'vertical'
            canvas:
                Color:
                    rgba: 0.8, 0.9, 1, 1
                RoundedRectangle:
                    pos: self.pos
                    size: self.size
                    radius: [10]

            Label:
                text: '执行的测试案例'
                font_size: '16sp'
                color: 0.3, 0.3, 0.3, 1
            Label:
                text: str(root.test_cases_executed)
                font_size: '32sp'
                bold: True
                color: 0.2, 0.5, 0.8, 1

        BoxLayout:
            orientation: 'vertical'
            canvas:
                Color:
                    rgba: 1, 0.9, 0.9, 1
                RoundedRectangle:
                    pos: self.pos
                    size: self.size
                    radius: [10]

            Label:
                text: '发现的缺陷'
                font_size: '16sp'
                color: 0.3, 0.3, 0.3, 1
            Label:
                text: str(root.bugs_found)
                font_size: '32sp'
                bold: True
                color: 0.8, 0.2, 0.2, 1

        BoxLayout:
            orientation: 'vertical'
            canvas:
                Color:
                    rgba: 0.9, 1, 0.9, 1
                RoundedRectangle:
                    pos: self.pos
                    size: self.size
                    radius: [10]

            Label:
                text: '测试等级'
                font_size: '16sp'
                color: 0.3, 0.3, 0.3, 1
            Label:
                text: root.level_display
                font_size: '18sp'
                bold: True
                color: 0.2, 0.6, 0.2, 1

    # 每日限制状态
    Label:
        text: root.daily_status
        font_size: '16sp'
        color: root.daily_status_color
        size_hint_y: None
        height: 30

    # 进度和状态信息
    BoxLayout:
        orientation: 'vertical'
        size_hint_y: None
        height: 60
        spacing: 5

        # Label:
            # text: root.progress_text
            # font_size: '18sp'
            # color: 0.4, 0.4, 0.4, 1

        Label:
            text: root.save_status
            font_size: '12sp'
            color: 0.5, 0.5, 0.5, 1

    # 当前测试案例显示区域
    BoxLayout:
        orientation: 'vertical'
        size_hint_y: None
        height: 150
        spacing: 5

        Label:
            text: '当前测试案例:'
            font_size: '18sp'
            color: 0.3, 0.3, 0.3, 1
            size_hint_y: None
            height: 30

        ScrollView:
            Label:
                text: root.current_test_case
                font_size: '16sp'
                color: 0.2, 0.2, 0.2, 1
                text_size: self.width, None
                size_hint_y: None
                height: self.texture_size[1]
                valign: 'top'
    # 主功能按钮
    Button:
        text: '执行测试案例'
        font_size: '22sp'
        bold: True
        background_color: root.execute_button_color
        background_normal: ''
        size_hint_y: None
        height: 70
        on_press: root.execute_test_case()
        disabled: (root.daily_limit - root.daily_executions) <= 0

    # 管理功能按钮
    GridLayout:
        cols: 4
        size_hint_y: None
        height: 50
        spacing: 10

        Button:
            text: '保存'
            font_size: '14sp'
            background_color: 0.3, 0.5, 0.8, 1
            background_normal: ''
            on_press: root.manual_save()

        Button:
            text: '历史'
            font_size: '14sp'
            background_color: 0.8, 0.6, 0.2, 1
            background_normal: ''
            on_press: root.show_history()

        Button:
            text: '重置'
            font_size: '14sp'
            background_color: 0.8, 0.3, 0.3, 1
            background_normal: ''
            on_press: root.reset_game()

        ToggleButton:
            id: sound_toggle
            text: '音效' if root.sound_enabled else '静音'
            font_size: '14sp'
            background_color: 0.4, 0.4, 0.6, 1
            background_normal: ''
            state: 'down' if root.sound_enabled else 'normal'
            on_press: root.toggle_sound()

    # 游戏说明
    BoxLayout:
        orientation: 'vertical'
        size_hint_y: None
        height: 100
        spacing: 5

        Label:
            text: '游戏说明:'
            font_size: '16sp'
            color: 0.5, 0.5, 0.5, 1
            size_hint_y: None
            height: 25

        GridLayout:
            cols: 3
            spacing: 5

            Label:
                text: '• 自动保存: 每30秒自动保存'
                font_size: '14sp'
                color: 0.5, 0.5, 0.5, 1
                text_size: self.width, None
                size_hint_y: None
                height: self.texture_size[1]

            Label:
                text: '• 手动保存: 点击"保存"按钮'
                font_size: '14sp'
                color: 0.5, 0.5, 0.5, 1
                text_size: self.width, None
                size_hint_y: None
                height: self.texture_size[1]

            Label:
                text: '• 查看历史: 点击"历史"按钮'
                font_size: '14sp'
                color: 0.5, 0.5, 0.5, 1
                text_size: self.width, None
                size_hint_y: None
                height: self.texture_size[1]

    BoxLayout:
        orientation: 'vertical'
        size_hint_y: None
        height: 120

        Label:
            text: '等级体系:'
            font_size: '16sp'
            color: 0.5, 0.5, 0.5, 1
            size_hint_y: None
            height: 25

        GridLayout:
            cols: 2
            spacing: 5

            Label:
                text: '初级测试工程师: Lv.1-3'
                font_size: '14sp'
                color: 0.3, 0.3, 0.3, 1
            Label:
                text: '中级测试工程师: Lv.1-5'
                font_size: '14sp'
                color: 0.3, 0.3, 0.3, 1
            Label:
                text: '高级测试工程师: Lv.1-7'
                font_size: '14sp'
                color: 0.3, 0.3, 0.3, 1
            Label:
                text: '测试专家: 封顶'
                font_size: '14sp'
                color: 0.8, 0.4, 0, 1